package xj.graph2d.app.prop;

import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;

import javax.swing.Icon;

import xj.graph2d.DrawAttr;

public class ColorFillIcon implements Icon {

  protected Dimension dim = new Dimension(16, 16);

  protected Color penColor = DrawAttr.getDefaultPenColor();

  protected Color fillColor = DrawAttr.getDefaultFillColor();

  public ColorFillIcon() {
  }

  public Color getPenColor() {
    return penColor;
  }

  public Color getFillColor() {
    return fillColor;
  }

  public void setPenColor(Color penColor) {
    this.penColor = penColor;
  }

  public void setFillColor(Color fillColor) {
    this.fillColor = fillColor;
  }

  public void paintIcon(Component c, Graphics g, int x, int y) {
    Color oldColor = g.getColor();
    // g.setColor(Color.lightGray);
    //
    // g.setColor(Color.white);
    // g.fillRect(x, y, getIconWidth(), getIconHeight());
    //
    g.setColor(fillColor);
    g.fill3DRect(x + 4, y + 4, 12, 12, true);
    g.setColor(penColor);
    g.fill3DRect(x, y, 12, 12, true);
    g.setColor(oldColor);
  }

  public int getIconWidth() {
    return dim.width;
  }

  public int getIconHeight() {
    return dim.height;
  }

}
